/**
 * \file CodeProfile.cpp
 * \brief CodeProfile definition class for windows
 * \author Edouard ROGE
 * \date 16 October 2012
 */

#include <Windows.h>
#include "Profiler.h"
#include "CodeProfile.h"


namespace Core
{
	namespace Profile
	{

		CodeProfile::CodeProfile(const char * _name)
		{
			m_iIndexTimeMeasure = Profiler::GetInstance().StartNewTimeMeasure(_name, std::this_thread::get_id());
		}

		CodeProfile::CodeProfile(const char * _name, std::thread::id _parentThreadId)
		{
			m_iIndexTimeMeasure = Profiler::GetInstance().StartNewTimeMeasure(_name, std::this_thread::get_id(), _parentThreadId);
		}

		CodeProfile::~CodeProfile()
		{
			if (m_iIndexTimeMeasure != -1)
			{
				Profiler::GetInstance().StopTimeMeasure(m_iIndexTimeMeasure, std::this_thread::get_id());
			}
		}
	}
}